<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>show Page</title>
    <meta charset="UTF-8">
    <script src="{{ url_for('static', filename='js/jquery-3.3.1.js') }}"></script>
    <script src="{{ url_for('static', filename='js/function_all.js') }}"></script>
</head>
<style>
    .tableShow{
 white-space: nowrap;
}
</style>
<body>
<!--展示结构-->

<div id="head">
</div>
<div id="container">
</div>



<script type="text/javascript">

    //将数据显示出来--动态生成表格--相似患者
    // var text_usr_dict = jsjx();//获取相似患者数据
    var table="<table border=1><th rowspan=\"2\">序号</th>";
        table+="<th rowspan=\"2\" width=200>自述</th>";
        table+=" <th rowspan=\"2\">[年龄] [体重] [身高]</th>";

        table+="<th colspan=\"2\">问诊单</th>";
        table+="<th rowspan=\"2\" width=100>舌照特征映射</th>";
        table+="<th rowspan=\"2\">舌照</th>";
        table+="<tr><th>问题</th><th>答案</th></tr>";

    var keyword = '{{keyword}}';
    //循环生成表格的每一行
    var inquiry = '{{inquiry}}';
    var text_usr_dict = {{text_usr_dict|safe}};

    for(var i=0;i<text_usr_dict.length;i++){
        //对问诊单部分的数据进行处理--方便左右两边显示
        //原始患者问诊单答案
        var originalAnswer = "";
        var inquiryDict = inquirySheet(inquiry);
        if(inquiryDict !== null){
            for(var key3 in inquiryDict){
            originalAnswer += inquiryDict[key3] + '\n';
            }
        }
        // console.log(text_usr_dict[i]['inquiry_sheet']);
        //问诊单问题
        var inqueryDictQuestion = inquirySheet(text_usr_dict[i]['inquiry_sheet']);
        var condition_report = inquirySheet(text_usr_dict[i]['condition_report']);
        var tongue_map_list = inquirySheet(text_usr_dict[i]['tongue_map']);

        // console.log(text_usr_dict[i]['condition_report']);
        var report = "";
        if(condition_report !== null){
            for(var ksey in condition_report){
            report += ksey + '\n';
            }
        }
        var reg = new RegExp( keyword , "g" )
        report = report.replace(reg,"<font color='red'>" + keyword +'</font>');

        // 舌照特征映射
        var tongue_map_string = "";
        if(tongue_map_list !== null){
            for(var tkey in tongue_map_list){
            tongue_map_string += tkey + '\n';
            }
        }
        console.log(inquirySheet(text_usr_dict[i]['tongue_map']));
        var tongue_dict = tongue_map_string.split(',');
        tongue_map_string = tongue_dict.join('\n').replace(/\n/g,'<br>');

        var keys = "";
        if(inqueryDictQuestion !== null){
            for(var key in inqueryDictQuestion){
            keys += key + '\n';
            }
        }
        //相似患者问诊单答案
        var similaryAnswer = "";
        if(inqueryDictQuestion !== null){
            for(var key2 in inqueryDictQuestion){
                similaryAnswer += inqueryDictQuestion[key2] + '\n';
            }
        }
        //将原始患者数据与相似患者数据进行对比，将相同的答案用红色标出
        var similaryAnswer2 = similaryAnswer.split('\n');
        var originalAnswer2 = originalAnswer.split('\n');

        //将问诊单问题和答案都进行换行显示--为了好看
        similaryAnswer = similaryAnswer2.join('\n');
        originalAnswer = originalAnswer2.join('\n');
        similaryAnswer = similaryAnswer.replace(/\n/g,'<br>');
        originalAnswer = originalAnswer.replace(/\n/g,'<br>');
        keys = keys.replace(/\n/g,'<br>');
        //表格的每一行
        table+="<tr><td>"+text_usr_dict[i].index+"</td>";
        table+= "<td>"+report+"</td>";
        table += "<td>"+text_usr_dict[i]['patient_information']+"</td>";


        table+= "<td  class='tableShow'>"+keys+"</td>";  //问题
        table+= "<td class='tableShow'>"+similaryAnswer+"</td>";  //相似病人答案
        table+= "<td>"+tongue_map_string+"</td>";
        table+= "<td><a href='' onclick='original_fun()'>舌照"+text_usr_dict[i].index+"</a></td>" +"</tr>"; //超链接，查图


    }
    table += "</table>";
    $('#container').html(table);
</script>
</body>
</html>


